package cn.deschen.common.exception;

import cn.deschen.common.api.IResCode;

/**
 * @Author hanbin_chen
 * @Description 全局异常
 * @DateTime 2021/6/1
 * @Version V1.0.0
 */
public class GlobalException extends RuntimeException{

    private IResCode errorCode;

    private Object data;


    public GlobalException(IResCode errorCode) {
        super(errorCode.getMessage());
        this.errorCode = errorCode;
    }

    public GlobalException(IResCode errorCode, String message) {
        super(message);
        this.errorCode = errorCode;
    }

    public GlobalException(IResCode errorCode, Object data) {
        super(errorCode.getMessage());
        this.errorCode = errorCode;
        this.data = data;
    }

    public GlobalException(IResCode errorCode, String message, Object data) {
        super(message);
        this.errorCode = errorCode;
        this.data = data;
    }

    public GlobalException(String message) {
        super(message);
    }

    public GlobalException(Throwable cause) {
        super(cause);
    }

    public GlobalException(String message, Throwable cause) {
        super(message, cause);
    }

    public IResCode getErrorCode() {
        return errorCode;
    }

    public Object getData() {
        return data;
    }
}
